Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy an oracle cronjob #1814

Merged
merged 22 commits into from
Dec 3, 2019
Merged

Deploy an oracle cronjob #1814

merged 22 commits into from
Dec 3, 2019

Conversation

yerdua
Copy link
Contributor

@yerdua yerdua commented Nov 20, 2019

Description

Helm chart and celotool command to deploy an oracle cronjob to a network.

Note: In order to get this working for baklavastaging, I merged in @tkporter's branch trevor/baklavastaging-nov-21. So, that branch should be merged into master first. Or this one should be merged into that one instead.

Tested

Tested by running the celotool command to deploy an oracle to baklavastaging, and confirming that the rates are reported to the network correctly.

Other Changes

Update contractkit's version to accurately reflect what's been published on npm

Related issues

.env Outdated
@@ -32,6 +32,12 @@ GETH_BOOTNODE_DOCKER_IMAGE_TAG="master"
CELOTOOL_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/celo-monorepo"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-dfdc3e8b26e98aa294b27e2b5621c184488a10db"

CELOCLI_STANDALONE_IMAGE_REPOSITORY="gcr.io/celo-testnet/celocli-standalone"
# TODO (yerdua): Change this to something actually reasonable
CELOCLI_STANDALONE_IMAGE_TAG="yerduaoracletest"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really doesn't seem ideal. I needed a docker image that can run the cli. The existing dockerfile has deeply hardcoded references to alfajores and runs a full node. In order to get something here, I built an image and pushed it manually.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add both env vars to all .env files?

@yerdua
Copy link
Contributor Author

yerdua commented Nov 20, 2019

There's a few incomplete things in this PR. The primary one is the handling of the docker image for celocli. I've merged the needed cli changes into master, but they're not yet published on npm. How best to handle tagging, versions, and the docker image building are all kind of opaque to me, so I'd appreciate some advice on how to do those right.

Also, there is no default oracle process. There's a docker image in a private repo, for my testnet, and for baklava. In an ideal world, there should probably be some default image, maybe just spitting out the exchange rate value specified in the config. Given the tight deadline, I think it's ok if the command fails when there's no oracle image for now.

Copy link
Contributor

@tkporter tkporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple small changes pending the new cli version


function helmParameters(celoEnv: string) {
return [
`--set celotool.image.repository=${fetchEnv('CELOTOOL_DOCKER_IMAGE_REPOSITORY')}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: some of these string literals are already found in envVar, if they aren't we should add them and use them to avoid hardcoding strings

`--set celotool.image.repository=${fetchEnv('CELOTOOL_DOCKER_IMAGE_REPOSITORY')}`,
`--set celotool.image.tag=${fetchEnv('CELOTOOL_DOCKER_IMAGE_TAG')}`,
`--set mnemonic="${fetchEnv(envVar.MNEMONIC)}"`,
`--set oracle.image.repository=${fetchEnv('ORACLE_DOCKER_IMAGE_REPOSITORY')}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used? same goes for any use of ORACLE_DOCKER_IMAGE_REPOSITORY

.env Outdated
@@ -32,6 +32,12 @@ GETH_BOOTNODE_DOCKER_IMAGE_TAG="master"
CELOTOOL_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/celo-monorepo"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-dfdc3e8b26e98aa294b27e2b5621c184488a10db"

CELOCLI_STANDALONE_IMAGE_REPOSITORY="gcr.io/celo-testnet/celocli-standalone"
# TODO (yerdua): Change this to something actually reasonable
CELOCLI_STANDALONE_IMAGE_TAG="yerduaoracletest"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add both env vars to all .env files?

spec:
initContainers:
- name: get-current-price
image: gcr.io/celo-testnet/oracle:{{ .Release.Namespace }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I think I get it now- should we set the repository and tag here similar to what we do for geth or celotool by having it depend on .env variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Thank you! This is where those unused envVars were supposed to go.

nodeSelector: {}

# Expects cron schedule syntax
oracleSchedule: "*/1 * * * *"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be helpful to add a comment what this schedule means in readable terms for people like myself that never remember the cron schedule structure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent idea. I had to look it up myself.
Do you think this makes sense here, or should it be an envVar like all the other ones?

@codecov
Copy link

codecov bot commented Nov 26, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@8f87dda). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1814   +/-   ##
=========================================
  Coverage          ?   74.45%           
=========================================
  Files             ?      281           
  Lines             ?     7817           
  Branches          ?      973           
=========================================
  Hits              ?     5820           
  Misses            ?     1880           
  Partials          ?      117
Flag Coverage Δ
#mobile 74.45% <ø> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f87dda...2f03d67. Read the comment docs.

@yerdua
Copy link
Contributor Author

yerdua commented Nov 26, 2019

Note: This branch has trevor/baklavastaging-nov-21 merged into it so deployment could work.

@yerdua yerdua changed the base branch from master to trevor/baklavastaging-nov-21 November 26, 2019 00:19
@yerdua yerdua changed the base branch from trevor/baklavastaging-nov-21 to master November 26, 2019 00:19
Copy link
Contributor

@jmrossy jmrossy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding a note at the top of the PR description that Trevor's branch changes must merge first before this :)

@yerdua yerdua changed the base branch from master to trevor/baklavastaging-nov-21 November 28, 2019 13:57
@yerdua yerdua changed the base branch from trevor/baklavastaging-nov-21 to master November 28, 2019 13:59
@yerdua yerdua removed their assignment Dec 2, 2019
@yerdua yerdua requested a review from m-chrzan as a code owner December 2, 2019 19:12
Comment on lines +41 to +49
CELOCLI_STANDALONE_IMAGE_REPOSITORY="gcr.io/celo-testnet/celocli-standalone"
CELOCLI_STANDALONE_IMAGE_TAG="0.0.30-beta2"

# Schedule for an oracle deployed via celotool, expressed in crontab syntax
# This schedule is "every 5th minute"
ORACLE_CRON_SCHEDULE="*/5 * * * *"

ORACLE_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/oracle"
ORACLE_DOCKER_IMAGE_TAG="baklavastaging"
Copy link
Contributor Author

@yerdua yerdua Dec 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The origin of this file is @tkporter's branch for baklavastaging deployment, as it is today (Dec 2). These vars are the only ones I added:

CELOCLI_STANDALONE_IMAGE_REPOSITORY
CELOCLI_STANDALONE_IMAGE_TAG
ORACLE_CRON_SCHEDULE
ORACLE_DOCKER_IMAGE_REPOSITORY
ORACLE_DOCKER_IMAGE_TAG

So, if there are merge conflicts in this file that do not involve these variables, the resolution is to pick whatever the other branch has.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only one of these that should be different for baklava is:
ORACLE_DOCKER_IMAGE_TAG="baklava"

That docker image already exists and is ready to go.

@@ -46,7 +47,7 @@ module.exports = deploymentForCoreContract<StableTokenInstance>(

for (const oracle of config.stableToken.oracles) {
console.info(`Adding ${oracle} as an Oracle for StableToken`)
await sortedOracles.addOracle(stableToken.address, oracle)
await sortedOracles.addOracle(stableToken.address, ensureHexLeader(oracle))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the 0x, the oracle silently doesn't get whitelisted correctly. This needs to be merged before baklava deployment.

Copy link
Contributor

@tkporter tkporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor comments, nice!

export const builder = {}

export const handler = async (argv: DestroyArgv) => {
await createClusterIfNotExists()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to remove this line to decrease the run time-- if we're destroying we should assume that the cluster exists & if it doesn't there's no need in creating it

- sh
- "-c"
- |
echo `./current_rate.sh` > /celo/.celo/current_price
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be able to just run ./current_rate.sh > /celo/.celo/current_price right?

@yerdua yerdua added the automerge Have PR merge automatically when checks pass label Dec 2, 2019
@celo-ci-bot-user celo-ci-bot-user merged commit cd2a2e2 into master Dec 3, 2019
@celo-ci-bot-user celo-ci-bot-user deleted the yerdua/oracle-cronjob branch December 3, 2019 01:41
aaronmgdr added a commit that referenced this pull request Dec 3, 2019
* master:
  Update docker image and instructions (#2000)
  DOCS correct typos (#1965)
  Add a space on payment request (#1935)
  expose signer through getValidator (#1997)
  Fix validator election migration bug with sorted list insertion (#1998)
  Deploy an oracle cronjob (#1814)
  Set default env in attestation service docker image as production (#1999)
  Attestation Bot POC (#1851)
  Only allow external RPCs for tx nodes (#1994)
aaronmgdr added a commit that referenced this pull request Dec 4, 2019
* master: (120 commits)
  Update docker image and instructions (#2000)
  DOCS correct typos (#1965)
  Add a space on payment request (#1935)
  expose signer through getValidator (#1997)
  Fix validator election migration bug with sorted list insertion (#1998)
  Deploy an oracle cronjob (#1814)
  Set default env in attestation service docker image as production (#1999)
  Attestation Bot POC (#1851)
  Only allow external RPCs for tx nodes (#1994)
  Specify web deps properly (#1950)
  Fix error calculating fees on currencies with high exchange rate (#1937)
  Small pre-stake-off CLI cleanup (#1953)
  Migrations: different CLabs groups gets different votes (#1960)
  [Wallet] Fix broken translation (decline, pay) (#1968)
  [Wallet]: Add Payments You've Requested notifications group & screen (#1902)
  [Wallet] Fix iOS bundle script failing with our monorepo setup (#1958)
  [NotificationService] Change exchange rate stored format (number timestamp and pair) (#1945)
  [Wallet] Fix premature hiding of syncing banner and increase some timeouts (#1957)
  Avoid `liner: function not supported in this terminal` (#1955)
  Support more human readable log output (#1929)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLabs SBAT operate a single oracle with Brownian motion
5 participants